<?php
/**
 * Created by PhpStorm.
 * User: miidi
 * Date: 2018/7/2
 * Time: 14:45
 */

namespace app\api\controller;

use app\api\model\Admin;
use app\api\validate\Idistenger;


class IsAdmin
{
  public function getId()
  {

    $validate = new Idistenger();
    $validate->geCheck();
    return 'success';

  }

  public function Login()
  {
    $username = $_REQUEST['username'];
    $password = $_REQUEST['password'];
    $result = Admin::where('username', $username)->find();
    if (!$result) {
      return json([
          'code' => 2,
          'message' => '用户不存在'
      ]);
    } else {
      $databasepassword = $result->password;
      if ($password == $databasepassword) {
        return json([
            'code' => 0,
            'data'=>$result,
            'message' => '登录成功'
        ]);
      } else {
        return json([
            'code' => 2,
            'message' => '密码不对'
        ]);
      }
    }

  }
}